﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using BLL.A;
using Model.A;

public partial class ActiveProductTrace_ViewActiveProduct_ViewATest_ATestItemViewbySNDT : System.Web.UI.Page
{
    private IList<ATestItemInfo> list;

    private string SN
    {
        get { return ViewState["SN"].ToString(); }
        set { ViewState["SN"] = value; }
    }
    private DateTime RecordTime
    {
        get { return DateTime.Parse(ViewState["RecordTime"].ToString()); }
        set { ViewState["RecordTime"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["SN"] != null && Request.QueryString["RecordTime"] != null)
            {
                SN = Request.QueryString["SN"].ToString();
                string dt = Request.QueryString["RecordTime"].ToString();
                RecordTime = new DateTime(int.Parse(dt.Substring(0, 4)), int.Parse(dt.Substring(4, 2)), int.Parse(dt.Substring(6, 2))
                    , int.Parse(dt.Substring(8, 2)), int.Parse(dt.Substring(10, 2)), int.Parse(dt.Substring(12, 2)));
                BindData();
            }
        }
    }

    protected void BindData()
    {
        ATestItem ati = new ATestItem();
        list = ati.ATestItem_GetbySNDT(SN, RecordTime);
        this.GridView1.DataSource = list;
        this.GridView1.DataBind();
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label lbl = (Label)e.Row.FindControl("Label1");
            lbl.Text = list.Count.ToString();
        }
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindData();
    }
}
